package com.mmall.pay.enums;

/**
 * @author gg
 * @version OptionTypeEnum.java, v 0.1 2019-05-27 19:54 gg
 */
public enum OptionTypeEnum {

    PAY(1, "支付"),
    REFUND(2, "退款"),
    ;

    private String desc;
    private Integer code;

    OptionTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * Getter method for property <tt>name</tt>.
     *
     * @return property value of name
     */
    public String getDesc() {
        return desc;
    }

    /**
     * Getter method for property <tt>value</tt>.
     *
     * @return property value of value
     */
    public Integer getCode() {
        return code;
    }

    public static OptionTypeEnum getByValue(Integer value) {
        OptionTypeEnum[] valueList = OptionTypeEnum.values();
        for (OptionTypeEnum v : valueList) {
            if (v.getCode().equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static String getName(Integer value) {
        OptionTypeEnum[] valueList = OptionTypeEnum.values();
        for (OptionTypeEnum v : valueList) {
            if (v.getCode().equals(value)) {
                return v.getDesc();
            }
        }
        return null;
    }
}